1 using System.Collections;
2 using
System.Collections.Generic;
3 using
UnityEngine;
4 using
UnityEditor;
5
6 [CustomPropertyDrawer(
typeof(GridCoords))]
7 public
class GridCoordsPropertyDrawer : PropertyDrawer {
8     
9
10     
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
11         EditorGUI.BeginProperty(position,label,property);
12         position = EditorGUI.PrefixLabel (position, GUIUtility.GetControlID (FocusType.Passive),
new GUIContent("GCoords (row,col)"));
13         
int indent = EditorGUI.indentLevel;
14         EditorGUI.indentLevel =
0;
15         Rect rowRect =
new Rect(position.x, position.y, 30, position.height);
16         Rect colRect =
new Rect(position.x + 35, position.y, 30, position.height);
17         EditorGUI.PropertyField(rowRect, property.FindPropertyRelative (
"row"), GUIContent.none);
18         EditorGUI.PropertyField(colRect, property.FindPropertyRelative (
"col"), GUIContent.none);
19
20         EditorGUI.indentLevel = indent;
21         EditorGUI.EndProperty();
22     }
23 }


Gõ tìm kiếm nhanh...